package org.javatribe.calculator.common;

import java.awt.*;
import java.util.EventObject;
import java.util.List;

import javax.swing.*;

/**
 * Created by Wenxin on 2017/9/15.
 */
public class EventWrapper implements Proccess {

    private final List<Handler> handlers;

    private final EventObject event;

    private final JFrame frame;

    private final String sourceName;

    private int index;

    public EventWrapper(List<Handler> handlers, EventObject event, JFrame frame, String sourceName) {
        this.handlers = handlers;
        this.event = event;
        this.frame = frame;
        this.sourceName = sourceName;
    }

    @Override
    public void proccess() {
        if (handlers.size()> index) {
            handlers.get(index++).handle(this);
        }
    }

    public EventObject getEvent() {
        return event;
    }

    public String getSourceName() {
        return sourceName;
    }

    public JFrame getFrame() {
        return frame;
    }
}
